package org.jsola.hr.web;

import javax.validation.Valid;

import org.jsola.core.Result;
import org.jsola.hr.constant.HrConstants;
import org.jsola.hr.dto.AttendGoOutDTO;
import org.jsola.hr.service.IAttendGoOutService;
import org.jsola.hr.vo.AttendGoOutVO;
import org.jsola.user.core.TokenUser;
import org.jsola.user.core.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 外出打卡
 * 
 * @author wxz
 *
 */
@RestController("hrAttendGoOutController")
@RequestMapping(HrConstants.API_PATH + "/v1/attendGoOut")
public class AttendGoOutController implements IAttendGoOutControllerAPI {
	
	@Autowired
	private IAttendGoOutService attendGoOutService;
	
	/**
	 * 外出打卡
	 * 
	 */
    @Override
    @PostMapping(value = "punch")
	public Result<AttendGoOutVO> punch(@Valid @RequestBody AttendGoOutDTO attendGoOutDTO) {
        TokenUser tokenUser = UserContext.getUser();

        return Result.success(
        		attendGoOutService.punch(attendGoOutDTO, tokenUser)
        );
	}

}
